package top.kaoshanji.p2ch15a;

/**
 * 代码清单-p2ch15a-442页b：synchronized代码块修饰的StaticCounter类
 * author kaoshanji
 * ^_^
 * create time 2025/2/23 18:12
 */
public class StaticCounter2 {

    // 静态属性
    private static int count = 0;

    public static void incr() {
        // 静态变量使用 类
        synchronized (StaticCounter2.class) {
            count++;
        }
    }

    public static int getCount() {
        synchronized (StaticCounter2.class) {
            return count;
        }
    }


}
